TOOLPATH = ../z_tools/
INCPATH = ../z_tools/haribote/

MAKE	 = $(TOOLPATH)make.exe -r
EDIMG	 = $(TOOLPATH)edimg.exe
IMGTOL 	 = $(TOOLPATH)imgtol.com
COPY 	 = copy
DEL		 = del

# 默认操作

default :
	$(MAKE) zinc.img

# 生成规则

zinc.img : core/boot.bin core/zinc.sys Makefile \
		hello/hello.hrb hello2/hello2.hrb winhello/winhello.hrb \
		stars/stars.hrb lines/lines.hrb walk/walk.hrb \
		noodle/noodle.hrb beepup/beepup.hrb color1/color1.hrb \
		color2/color2.hrb prime/prime.hrb cat/cat.hrb notrec/notrec.hrb \
		bball/bball.hrb invader/invader.hrb
	$(EDIMG) imgin:../z_tools/fdimg0at.tek \
		wbinimg src:core/boot.bin len:512 from:0 to:0 \
		copy from:core/zinc.sys to:@: \
		copy from:core/boot.nas to:@: \
		copy from:make.bat to:@: \
		copy from:hello/hello.hrb to:@: \
		copy from:hello2/hello2.hrb to:@: \
		copy from:winhello/winhello.hrb to:@: \
		copy from:stars/stars.hrb to:@: \
		copy from:lines/lines.hrb to:@: \
		copy from:walk/walk.hrb to:@: \
		copy from:noodle/noodle.hrb to:@: \
		copy from:beepup/beepup.hrb to:@: \
		copy from:color1/color1.hrb to:@: \
		copy from:color2/color2.hrb to:@: \
		copy from:prime/prime.hrb to:@: \
		copy from:cat/cat.hrb to:@: \
		copy from:notrec/notrec.hrb to:@: \
		copy from:bball/bball.hrb to:@: \
		copy from:invader/invader.hrb to:@: \
		imgout:zinc.img

# 伪目标

.PHONY : run install all run_all install_all run_core clean src_only \
		clean_all src_only_all refresh

run :
	$(MAKE) zinc.img
	$(COPY) zinc.img ..\z_tools\qemu\fdimage0.bin
	$(MAKE) -C ../z_tools/qemu

install :
	$(MAKE) zinc.img
	$(IMGTOL) w a: zinc.img

all :
	$(MAKE) -C core
	$(MAKE) -C apilib

	$(MAKE) -C hello
	$(MAKE) -C hello2
	$(MAKE) -C winhello
	$(MAKE) -C stars
	$(MAKE) -C lines
	$(MAKE) -C walk
	$(MAKE) -C noodle
	$(MAKE) -C beepup
	$(MAKE) -C color1
	$(MAKE) -C color2
	$(MAKE) -C prime
	$(MAKE) -C cat
	$(MAKE) -C notrec
	$(MAKE) -C bball
	$(MAKE) -C invader
	$(MAKE) zinc.img

run_all :
	$(MAKE) all
	$(COPY) zinc.img ..\z_tools\qemu\fdimage0.bin
	$(MAKE) -C ../z_tools/qemu

install_all :
	$(MAKE) all
	$(IMGTOL) w a: zinc.img

run_core :
	$(MAKE) -C zinc
	$(MAKE) run		

clean :
	-$(DEL) *.bin
	-$(DEL) *.lst
	-$(DEL) *.obj
	-$(DEL) *.hrb
	-$(DEL) *.map
	-$(DEL) *.bim
	-$(DEL) zinc.sys
	-$(DEL) zinc.img

src_only :
	$(MAKE) clean
	-$(DEL) zinc.img

clean_all :
	$(MAKE) -C core     clean
	$(MAKE) -C apilib   clean
	$(MAKE) -C hello    clean
	$(MAKE) -C hello2   clean
	$(MAKE) -C winhello clean
	$(MAKE) -C stars    clean
	$(MAKE) -C lines    clean
	$(MAKE) -C walk     clean
	$(MAKE) -C noodle   clean
	$(MAKE) -C beepup   clean
	$(MAKE) -C color1   clean
	$(MAKE) -C color2   clean
	$(MAKE) -C prime    clean
	$(MAKE) -C cat      clean
	$(MAKE) -C notrec   clean
	$(MAKE) -C bball	clean
	$(MAKE) -C invader	clean

src_only_all :
	$(MAKE) -C core     src_only
	$(MAKE) -C apilib   src_only
	$(MAKE) -C hello    src_only
	$(MAKE) -C hello2   src_only
	$(MAKE) -C winhello src_only
	$(MAKE) -C stars    src_only
	$(MAKE) -C lines    src_only
	$(MAKE) -C walk     src_only
	$(MAKE) -C noodle   src_only
	$(MAKE) -C beepup   src_only
	$(MAKE) -C color1   src_only
	$(MAKE) -C color2   src_only
	$(MAKE) -C prime    src_only
	$(MAKE) -C cat      src_only
	$(MAKE) -C notrec   src_only
	$(MAKE) -C bball    src_only
	$(MAKE) -C invader  src_only
	-$(DEL) zinc.img

refresh :
	$(MAKE) all
	$(MAKE) clean_all
	-$(DEL) zinc.img
